<template>
    <div>
<h1>科室显示</h1>
<a href="https://localhost:7258/api/Lode/UpFile">导出</a>
<input type="text" placeholder="根据科室名称模糊查" v-model="dataps.names">
<input type="date" v-model="dataps.sdate">-- <input type="date" v-model="dataps.edate">
  <input type="button" value="查询" class="btn btn-success" @click="GetShow">
  <input type="button" value="清空" class="btn btn-success" @click="Qk">

<table class="table">
    <thead>
        <tr>
            <td>科室名称</td>
            <td>科室人数</td>
            <td>科室描述</td>
            <td>创建日期</td>
            <td>操作</td>
        </tr>
    </thead>
    <tbody>
    <tr v-for="d in data">
            <td>{{d.kName}}</td>
            <td>{{d.numRs}}</td>
            <td>{{d.magges}}</td>
            <td>{{moment(d.datetimes).format("YYYY-MM-DD")}}</td>
            <td>
                <input type="button" value="逻辑删除" class="btn btn-success" @click="Dels(d.kid)">
                <input type="button" value="修改" class="btn btn-success" @click="UpKs(d.kid)">
            </td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import moment from 'moment';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router=useRouter();
onMounted(()=>{
    GetShow();
})
const dataps=ref({
    names:"",
    sdate:"",
    edate:""
})
const data=ref([{
      "kid": 2,
    "kName": "外科",
    "numRs": 13,
    "magges": "有超高的临床经验",
    "datetimes": "2025-05-19T10:26:05.0634377",
    "isDel": false
}])
const GetShow=()=>{
    axios.get("/api/Ks/GetKs",{params:dataps.value}).then(res=>{
        data.value=res.data;
    })
}

//逻辑删除
const Dels=(sid:any)=>{
    if(!confirm("确定要删除吗"))
{
    return;
}
axios.delete("/api/Ks/IsDels",{params:{id:sid}}).then(res=>{
    if(res.data>0)
{
    alert("删除成功");
    GetShow();
}
else
{
    alert("删除失败");
}
})
}
//修改
const UpKs=(aid:any)=>{
router.push({path:"/Ups",query:{id:aid}})
}

//清空
const Qk=()=>{
    dataps.value.names="";
    dataps.value.sdate="";
    dataps.value.edate="";
}
</script>

<style scoped>

</style>